#!/usr/bin/python

import wsgiserver
import sys
import os
import django.core.handlers.wsgi


if __name__ == "__main__":

	try:
            pid = os.fork()
            if pid > 0:
                sys.exit(0)
        except OSError, e:
            sys.exit(1)

        os.setsid()
        os.umask(0)
	sys.path.append('/srv/http/django/sample-site')
	os.environ['DJANGO_SETTINGS_MODULE'] = 'sample-site.settings'
	server = wsgiserver.CherryPyWSGIServer(
		('127.0.0.1', 8020),
		django.core.handlers.wsgi.WSGIHandler(),
		server_name='sample-site.com',
		numthreads = 20,
	)
	try:
		server.start()
	except KeyboardInterrupt:
		server.stop()
